package com.zygh.lz.controller;

import com.zygh.lz.entity.Xarea;
import com.zygh.lz.entity.remould.Xareas;
import com.zygh.lz.service.SignService;
import com.zygh.lz.service.XareaService;
import com.zygh.lz.stapprove.ResultUtil;
import com.zygh.lz.stapprove.SysPcLog;
import com.zygh.lz.stapprove.ViLog;
import com.zygh.lz.vo.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;

@Api(tags = "区域标注类", description = "XareaController")
@RequestMapping("/Xarea")
@RestController
public class XareaController {
    @Autowired
    private XareaService xareaService;
    @Resource
    private SignService signService;
    @ApiOperation("根据大队，中队，岗位，中队领导")
    @GetMapping("selectXareabycondition")
    public ResultBean selectXareabycondition(String battalion, String detachment, String station, String leader, String grid, String type) {
        return xareaService.selectXareabycondition(battalion, detachment, station, leader, grid, type);
    }

    @PostMapping("insertXarea")
    @ApiOperation("新增交警巡查区域")
    //@SysPcLog(module = "新增交警巡查区域",operation = "新增")
    public ResultBean insertXarea(@RequestBody Xarea xarea) {
        return xareaService.insertXarea(xarea);
    }

    @ApiOperation("修改交警巡查区域")
    @PostMapping("updateXarea")
    //@SysPcLog(module = "修改交警巡查区域",operation = "修改")
    public ResultBean updateXarea(@RequestBody Xarea xarea) {
        return xareaService.updateXarea(xarea);
    }

    @ApiOperation("删除交警巡查区域")
    @GetMapping("deleteXarea")
    //@SysPcLog(module = "删除交警巡查区域",operation = "删除")
    public ResultBean deleteXarea(Integer id, String updateBy) {
        return xareaService.deleteXarea(id, updateBy);
    }

    @ApiOperation("根据名字模糊查询")
    @GetMapping("selectXareaByName")
    public ResultBean selectXareaByName(String name, String battalion, String detachment) {
        return xareaService.selectXareaByName(name, battalion, detachment);
    }

    @ApiOperation("查询所有区域")
    @GetMapping("selectXareaAll")
    public ResultBean selectXareaAll() {
        return xareaService.selectXareaAll();
    }

    @ApiOperation("查询所有区域里民警应到、实到人数")
    @GetMapping("selectonlineNumber")
    public ResultBean selectonlineNumber(Integer id) {
        return xareaService.selectonlineNumber(id);
    }

    //按大队区分所有在线警力
    @GetMapping("selectpolice")
    public ResultBean selectpolice() {
        return xareaService.selectpolice();
    }

    @GetMapping("selectqt")
    public ResultBean selectqt(String conment, String battalion) {
        return xareaService.selectqt(conment, battalion);
    }

    @ApiOperation("日间固定岗/高峰岗")
    @GetMapping("selectfixationRJ")
    public ResultBean selectfixationRJ(String station, String battalion) {
        return xareaService.selectfixationRJ(station, battalion);
    }

    //日间重点机关岗
    @ApiOperation("日间重点机关岗")
    @GetMapping("selectemphasisRJ")
    public ResultBean selectemphasisRJ(String battalion) {
        return xareaService.selectemphasisRJ(battalion);
    }

    //日间铁骑
    @ApiOperation("日间铁骑")
    @GetMapping("selectcavalryRJ")
    //@ViLog(logType = "1", module = "日间铁骑")
    public ResultBean selectcavalryRJ(String battalion) {
        return xareaService.selectcavalryRJ(battalion);
    }

    //日间网格警力部署
    @ApiOperation("日间网格警力部署")
    @GetMapping("selectgriddingRJ")
    //@ViLog(logType = "1", module = "日间网格警力部署")
    public ResultBean selectgriddingRJ(String battalion) {
        return xareaService.selectgriddingRJ(battalion);
    }

    //日间高速岗部署
    @ApiOperation("日间高速岗部署")
    @GetMapping("selectexpresswayRJ")
    //@ViLog(logType = "1", module = "日间高速岗部署")
    public ResultBean selectexpresswayRJ(String station, String battalion) {
        return xareaService.selectexpresswayRJ(station, battalion);
    }


    //全部在线人
    @ApiOperation("全部在线人")
    @GetMapping("selectInformant")
    //@ViLog(logType = "1", module = "全部在线人")
    public ResultBean selectInformant() {
        return xareaService.selectInformant();
    }

    //夜间夜巡
    @ApiOperation("夜间夜巡")
    @GetMapping("selectNightTour")
    //@ViLog(logType = "1", module = "夜间夜巡")
    public ResultBean selectNightTour(String battalion) {
        return xareaService.selectNightTour(battalion);
    }

    //夜间快速警力部署
    @ApiOperation("夜间快速警力部署")
    @GetMapping("selectceleritygs")
    //@ViLog(logType = "1", module = "夜间快速警力部署")
    public ResultBean selectcelerity(String station, String battalion) {
        return xareaService.selectcelerity(station, battalion);
    }

    //夜间高速警力部署
    @ApiOperation("夜间高速警力部署")
    @GetMapping("selectceleritygts")
    //@ViLog(logType = "1", module = "夜间高速警力部署")
    public ResultBean selectceleritygts(String station, String battalion) {
        return xareaService.selectceleritygs(station, battalion);
    }

    //夜间其他警力部署
    @ApiOperation("夜间其他警力部署")
    @GetMapping("selectqita")
    //@ViLog(logType = "1", module = "夜间其他警力部署")
    public ResultBean selectqita(String battalion) {
        return xareaService.selectqita(battalion);
    }

    @ApiOperation("九主六块十六示范区")
    @GetMapping("selectDemonstrationPlot")
    public ResultBean selectDemonstrationPlot(String station, String battalion) {
        return xareaService.selectDemonstrationPlot(station, battalion);
    }

    @ApiOperation("根据区域名字模糊匹配部署警力")
    @GetMapping("selctStrength")
    public ResultBean selctStrength(String name, String battalion) {
        return xareaService.selctStrength(name, battalion);
    }

    @ApiOperation("九主六块警力详情")
    @GetMapping("selectAllByDemonstration")
    public ResultBean selectAllByDemonstration(String station, String battalion) {
        return xareaService.selectAllByDemonstration(station, battalion);
    }

    /**
     * 根据id,大队，岗位查询区域详情
     *
     * @param id         区域id
     * @param sectionDid 大队id
     * @param grid       岗位
     */
    @ApiOperation("根据id,大队，岗位查询区域详情")
    @GetMapping("findDetailsByInfo")
    public ResultBean findDetailsByInfo(Integer id, Integer sectionDid, String grid) {
        return xareaService.findDetailsByInfo(id, sectionDid, grid);
    }

    @ApiOperation("根据区域id查询人员详情")
    @GetMapping("findStaffInfo")
    public ResultBean findStaffInfo(Integer id) {
        return xareaService.findStaffInfo(id);
    }

    @ApiOperation("根据条件统计各时段岗位在线率")
    @GetMapping("countXarea")
    public List<HashMap> countXarea(String rwsd, String battalion, String startTime, String endTime) {
        return xareaService.countXarea(rwsd, battalion, startTime, endTime);
    }

    @ApiOperation("空岗统计 当天没有签到的岗位统计")
    @GetMapping("konggangRemind")
    public ResultBean konggangRemind(String battalion) {
        return xareaService.konggangRemind(battalion);
    }

    @ApiOperation("日间机动岗统计")
    @GetMapping("findMobile")
    public ResultBean findMobile(String battalion) {
        return xareaService.findMobile(battalion);
    }

    @ApiOperation("各大队缺勤岗位")
    @GetMapping("findAbsent")
    public ResultBean findAbsent(String station, String battalion) {
        return xareaService.findAbsent(station, battalion);
    }

    @ApiOperation("根据岗位类型和中队id查询岗位")
    @GetMapping("findXareaByInfo")
    public List<Xarea> findXareaByInfo(String station, Integer id) {
        return xareaService.findXareaByInfo(station, id);
    }

    /**
     * 各大队缺勤岗位
     */
    @ApiOperation("根据id查询岗位信息")
    @GetMapping("selectByPrimaryKey")
    public ResultBean selectByPrimaryKey(Integer id) {
        return xareaService.selectByPrimaryKey(id);
    }

    /**
     * ================================PC端首页右侧岗位详情栏信息改造========================================
     */

    @ApiOperation("PC首页右侧详情，大队详情信息")
    @GetMapping("findBattalionInfo")
    public ResultBean findBattalionInfo(String battalion, String station) {
        return xareaService.findBattalionInfo(battalion, station);
    }

    @ApiOperation("PC首页右侧详情，中队详情信息")
    @GetMapping("findDetachmentInfo")
    public ResultBean findDetachmentInfo(String battalion, String station) {
        return xareaService.findDetachmentInfo(battalion, station);
    }

    @ApiOperation("PC首页右侧详情，人员详情信息")
    @GetMapping("findStaffDetail")
    public ResultBean findStaffDetail(Xareas xareas) {
        return xareaService.findStaffDetail(xareas);
    }

    @ApiOperation("PC日常勤务岗位列表")
    @GetMapping("findStation")
    public ResultBean findStation(Integer sectionId) {
        return ResultUtil.setOK("success", xareaService.findStation(sectionId));
    }

    @ApiOperation("PC日常勤务根据大队和岗位查询详情")
    @GetMapping("findXareaByStation")
    public ResultBean findXareaByStation(String sectionId, String station,String name) {
        return ResultUtil.setOK("success", xareaService.findXareaByStation(sectionId, station,name));
    }


    @ApiOperation("PC日常勤务岗位坐标")
    @GetMapping("findXareaCoordinate")
    public ResultBean findXareaCoordinate(String battalion, String station) {
        return ResultUtil.setOK("success", xareaService.findXareaCoordinate(battalion, station));
    }

    @ApiOperation("PC日常勤务根据岗位查询岗位部署人员")
    @GetMapping("findStaffByXareaId")
    public ResultBean findStaffByXareaId(Integer id) {
        return ResultUtil.setOK("success", xareaService.findStaffByXareaId(id));
    }


    @ApiOperation("PC日常勤务根据岗位id查询岗位部署人员")
    @GetMapping("findXareaById")
    public ResultBean findXareaById(Integer id) {
        return ResultUtil.setOK("success", xareaService.findXareaById(id));
    }


    @ApiOperation("获取勤务模式列表")
    @GetMapping("findXareaModeAll")
    public ResultBean findXareaModeAll() {
        return ResultUtil.setOK("success", xareaService.findXareaModeAll());
    }

    @ApiOperation("数据统计，岗位统计导出")
    @PostMapping("/export/count")
    public ResultBean exportCount(HttpServletResponse response){
//        signService.exportCount(response);
        signService.exportPostCount(response);
        return ResultUtil.setOK("导出成功",null);
    }

    @ApiOperation("日常勤务，岗位统计导出")
    @PostMapping("/export/dailyService")
    public ResultBean dailyService(HttpServletResponse response){
        signService.dailyService(response);
        return ResultUtil.setOK("导出成功",null);
    }

}
